package com.doit.demo_Annotation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class demo02 {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException {
        Class c = demo01.class;
        Object obj = c.newInstance();
        Method[] declaredMethods = c.getDeclaredMethods();//获得所有方法
        for (Method method : declaredMethods) {
            boolean b = method.isAnnotationPresent(MyAnnotation.class);//判断方法上是否有注解
            if (b){
                method.invoke(obj);
            }
        }
    }
}
